package utils;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Code {
    private String file = null; // 源程序

    public Code(String f) {
        file = f;
    }

    @Override
    public String toString() {
        try {
            FileReader fileReader = new FileReader(this.file);
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            String tmp = null;
            while ((tmp = bufferedReader.readLine()) != null) {
                System.out.println(tmp);
            }
            bufferedReader.close();
            fileReader.close();
        } catch (FileNotFoundException e) {
            System.out.println("没有找到这个源文件");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("读写文件异常");
            e.printStackTrace();
        }
        return "*****源代码结束*****";
    }
}
